package com.song.email.util.common;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

public class FileUtil {
	
	public static List<String> readFile2List(String path){
		if(StringUtils.isBlank(path)){
			return null;	
		}
		List<String> list = new ArrayList<String>();
		FileReader fReader = null;
		BufferedReader bReader = null;
		try {
			fReader = new FileReader(new File(path));
			bReader = new BufferedReader(fReader);
			String temp = null;
			while((temp = bReader.readLine()) != null){
				if(StringUtils.isNotBlank(temp)){
					list.add(temp.trim());
				}
				temp = null;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(bReader != null){
				try {
					bReader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if(null != fReader){
				try {
					fReader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		
		return list;
	}
}
